home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / dtscpluslibrary / sources / colorpickertest.cp < prev    next >
Encoding:
Text File  |  2000-09-28  |  2.8 KB  |  84 lines

  1. /*
  2.     File:        ColorPickerTest.cp
  3.  
  4.     Contains:    TColorPicker is a simple color picker utility class    
  5.                   TColorPickerTest.cp contains the TColorPicker test function definitions. 
  6.  
  7.     Written by: Kent Sandvik    
  8.  
  9.     Copyright:    Copyright © 1993-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24. #ifndef _COLORPICKER
  25. #include "ColorPicker.h"
  26. #endif
  27.  
  28. void main(void)
  29. {
  30.     cout << "Start of the TColorPicker object test…\n";
  31.  
  32.     // Initialize needed toolbox entries
  33.     ::InitGraf(&qd.thePort);
  34.     ::InitWindows();
  35.     ::InitDialogs(NULL);
  36.  
  37.     //    Create a TColor Picker.    
  38.     TColorPicker myPicker;
  39.  
  40.     //    Select a value, show it three times to check out that it remembers the color.
  41.     for (int i = 0; i < 3; i++)
  42.         myPicker.Select("\pI want a color, pleaaaase");
  43.  
  44.     //    Show RGB values from last selection.    
  45.     cout << "Last selected RGB has the following values: \n";
  46.     RGBColor foo = myPicker.GetSelectedColor();
  47.     cout << foo.red << " " << foo.green << " " << foo.blue << "\n";
  48.  
  49.     //    Show CMY values from last selection.    
  50.     CMYColor myCMY = myPicker.GetSelectedCMYColor();
  51.     cout << "Last selected RGB has the following CMY values: \n";
  52.     cout << myCMY.cyan << " " << myCMY.magenta << " " << myCMY.yellow << "\n";
  53.  
  54.     //    Show HSL values from last selection.
  55.     HSLColor myHSL = myPicker.GetSelectedHSLColor();
  56.     cout << "Last selected RGB has the following HSL values: \n";
  57.     cout << myHSL.hue << " " << myHSL.saturation << " " << myHSL.lightness << "\n";
  58.  
  59.     //    Show HSV values from last selection.
  60.     HSVColor myHSV = myPicker.GetSelectedHSVColor();
  61.     cout << "Last selected RGB has the following HSV values: \n";
  62.     cout << myHSV.hue << " " << myHSV.saturation << " " << myHSV.value << "\n";
  63.  
  64.     //    Reset and show the picker once again.
  65.     myPicker.Reset();
  66.     myPicker.Select();
  67.  
  68.     //    Create a plain color picker that neith.er keeps track of original value, neither has a string. 
  69.     //    for the dialog message.
  70.     TColorPicker plainOne(false);
  71.     for (int j = 0; j < 3; j++)
  72.         plainOne.Select("\p");
  73.  
  74.     cout << "End of the TColorPicker object test!\n";
  75. }
  76.  
  77. // _________________________________________________________________________________________________________ //
  78.  
  79. /*    Change History (most recent last):
  80.   No        Init.    Date        Comment
  81.   1            khs        1/3/93        New file
  82.   2            khs        1/5/93        Cleanup
  83. */
  84.